﻿export default url => {
    const crud = window.$crud(url)

    // 提交评估（包含年审）
    const addAssess = (data) => window.$axios({
        url: `erpCase/supplierrisk`,
        method: 'post',
        data: data
    })
    const getAssess = (supplierid, risktype) => window.$axios({
        url: `erpCase/supplierrisk/${supplierid}/${risktype}`,
        method: 'get'
    })

    const getYear = (id) => window.$axios({
        url: `erpCase/supplierrisk/${id}`,
        method: 'get'
    })

    const getYearBySupplierId = (supplierid) => window.$axios({
        url: `erpCase/supplierrisk/year/${supplierid}`,
        method: 'get'
    })


    // 转正申请
    const addFormal = (data) => window.$axios({
        url: `erpCase/supplierformal`,
        method: 'post',
        data: data
    })
    const updateFormal = (id, data) => window.$axios({
        url: `erpCase/supplierformal/${id}`,
        method: 'put',
        data: data
    })
    const getFormal = (id) => window.$axios({
        url: `erpCase/supplierformal/${id}`,
        method: 'get',
    })

    const getFormalBySupplier = (supplierId) => window.$axios({
        url: `erpCase/supplierformal/bysupplier/${supplierId}`,
        method: 'get',
    })

    // 供应商时间轴信息
    const getTimeList = (supplierId) => window.$axios({
        url: `erpCase/supplytimes`,
        method: 'get',
        params: {
            f_SupplierId: supplierId
        }
    })




    //  获取供货清单
    const supplymaterials = (data) => window.$axios({
        url: `erpCase/supplymaterials`,
        method: 'get',
        params: data
    })
    const supplymaterialpage = (data) => window.$axios({
        url: `erpCase/supplymaterial/page`,
        method: 'get',
        params: data
    })

    // 物料列表
    const material = (data) => window.$axios({
        url: `erpCase/material/page`,
        method: 'get',
        data: data,
    })

    // 添加供货清单
    const addMaterial = (data) => window.$axios({
        url: `erpcase/supplymaterial`,
        method: 'post',
        data: data,
    })
    // 更新供货清单信息
    const updateMaterial = (id, data) => window.$axios({
        url: `erpcase/supplymaterial/${id}`,
        method: 'put',
        data: data,
    })
    // Delete供货清单
    const removeMaterial = (id) => window.$axios({
        url: `erpcase/supplymaterial/${id}`,
        method: 'delete',
    })

    // 获取单条物料信息
    const oneMaterial = (id) => window.$axios({
        url: `erpcase/supplymaterial/${id}`,
        method: 'get',
    })

    // 供货清单历史记录
    const supplypricelogs = (data) => window.$axios({
        url: `erpcase/supplypricelogs`,
        method: 'get',
        params: data,
    })




    return {
        ...crud,
        addAssess,
        getAssess,

        addFormal,
        updateFormal,
        getFormal,
        getFormalBySupplier,

        supplymaterials,
        supplymaterialpage,
        material,
        oneMaterial,

        addMaterial,
        updateMaterial,
        removeMaterial,

        supplypricelogs,


        getTimeList,
        getYear,
        getYearBySupplierId
    }
}